﻿@page "/SysOperator/Details/{id}"
@using SelfService.ViewModel.SysOperatorVMs;
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" >
    <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">

        <Display @bind-Value="@Model.Entity.Name"   ShowLabel="true"/>
        <Display @bind-Value="@Model.Entity.Code"  />
        <Display @bind-Value="@Model.Entity.Description"   ShowLabel="true"/>
        <Display @bind-Value="@Model.Entity.GroupId" Lookup="@AllSysOperatorGroups"  ShowLabel="true"/>
        <Display @bind-Value="@Model.Entity.ClientId" Lookup="@AllSysClients"  ShowLabel="true"/>
        <Display @bind-Value="@Model.Entity.Password"   ShowLabel="true"/>
        <Display @bind-Value="@Model.Entity.Token"   ShowLabel="true"/>
        <Display @bind-Value="@Model.Entity.IsEnable"   ShowLabel="true"/>
    </Row>
    <div class="modal-footer table-modal-footer">
        <Button Color="Color.Primary" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Close"]" OnClick="OnClose" />
    </div>
</ValidateForm>

@code {

    private SysOperatorVM Model = null;
    private ValidateForm vform { get; set; }
    [Parameter]
    public string id { get; set; }

    private List<SelectedItem> AllSysOperatorGroups = new List<SelectedItem>();

    private List<SelectedItem> AllSysClients = new List<SelectedItem>();


    protected override async Task OnInitializedAsync()
    {

        AllSysOperatorGroups = await WtmBlazor.Api.CallItemsApi("/api/SysOperator/GetSysOperatorGroups", placeholder: WtmBlazor.Localizer["Sys.All"]);

        AllSysClients = await WtmBlazor.Api.CallItemsApi("/api/SysOperator/GetSysClients", placeholder: WtmBlazor.Localizer["Sys.All"]);

        var rv = await WtmBlazor.Api.CallAPI<SysOperatorVM>($"/api/SysOperator/{id}");
        Model = rv.Data;
    }

    public void OnClose()
    {
        CloseDialog();
    }

}
